import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'hot_today_bloc.dart';
import 'hot_today_event.dart';
import 'hot_today_state.dart';

class HotTodayPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (BuildContext context) => HotTodayBloc()..add(InitEvent()),
      child: Builder(builder: (context) => _buildPage(context)),
    );
  }

  Widget _buildPage(BuildContext context) {
    final bloc = BlocProvider.of<HotTodayBloc>(context);
    return BlocBuilder<HotTodayBloc, HotTodayState>(
        bloc: bloc,
        builder: (_, HotTodayState state) {
          return Center(child: Text("${state.model.result?.list?.first.title}"),);
        }
    );
  }
}

